package com.bootcamo.javase.oop;

import java.sql.SQLOutput;

/**
 * @program: FinalCode
 * @description: GrrandFather, Father, son class
 * @author: Keyu Li
 * @create: 2021-09-01 14:20
 **/

public class Demo {
    public static void main(String[] args) {
        GrandFather gf = new GrandFather();
        Father fs = new Son();
        fs.test();
        fs.testFather();
        Son ss = new Son();
        ss.testFather();
    }
}

class GrandFather {
    int gA, a;
    static int sss;

    {
        gA = 100;
        a = 200;
    }

    public GrandFather() {
    }

    void testGrand() {
        System.out.println("testGrand!");
    }

    void test() {
        System.out.println("Grandfather test! a=" + a);
    }
}

class Father extends GrandFather {
    int fA, a;

    {
        fA = 10;
        a = 20;
    }

    public Father() {
    }

    void testFather() {
        System.out.println("testFather!");
        this.test();
    }

    @Override
    void test() {
        System.out.println("Father test! a=" + a);
    }
}

class Son extends Father {
    int sA, a;

    {
        sA = 1;
        a = 2;
    }

    public Son() {
    }

    public Son(int a) {
        this.a = a;
    }

    public Son(int sA, int a) {
        this.sA = sA;
        this.a = a;
    }

    void testSon() {
        System.out.println("testSon!");
    }

    @Override
    void test() {
        System.out.println("Son test! a=" + a);
    }
}